<?
require_once('ConverterBase.php');

class TextConverter extends ConverterBase {
	private $enableTrim = false;
	public function enableTrim($value) { $this->enableTrim= (boolean)$value; return $this; }
	public function isTriming() { return $this->enableTrim; }
	
	protected function toDatatype($string) {
		if (get_magic_quotes_gpc())
			$string= stripslashes($string);
		$string = str_replace("\r","",(string)$string);
		if ($this->isTriming())
			$string = trim($string);
		return (string)$string;
	}
	protected function toString($object) {
		if (empty($object) && $object !== '0') return '';
		return (string)$object;
	}
}
